package ar.edu.unicen.exa.oop.bbquery.forum_service.crawler;

import java.util.HashMap;

/**
 * un factory method para abstraer la creacion de las cosas y un flyweight para
 * no crear muchos objetos.
 * 
 * @author nicolas
 * 
 */
public class DefaultCrawlerAddressFwFactory implements CrawlerAddressFactory {

    HashMap<String, CrawlerAddress> hm;

    public DefaultCrawlerAddressFwFactory() {
	hm = new HashMap<String, CrawlerAddress>();
    }

    /*
     * (non-Javadoc)
     * 
     * @see
     * ar.edu.unicen.exa.oop.bbquery.forum_service.crawler.ICrawlerDataFactory
     * #getData(java.lang.String)
     */
    public CrawlerAddress getData(String key) {
	CrawlerAddress f = hm.get(key);
	if (f != null) {
	    return f;
	} else {
	    CrawlerAddress d = createCrawlerData();
	    hm.put(key, d);
	    return d;
	}
    }

    /*
     * hacerlas abstract ...
     */

    public static CrawlerAddress createCrawlerData() {
	return new StrCrawlerAddress();
    }
}
